package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.FapiaoBean;
import com.lwj.liwanjia.impl.FapiaoView;
import com.lwj.liwanjia.model.FapiaoModel;

import java.util.Map;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/16.
 */

public class FapiaoPresenter {
    private FapiaoModel fapiaoModel;
    private FapiaoView fapiaoView;

    public FapiaoPresenter(FapiaoView fapiaoView) {
        this.fapiaoView = fapiaoView;
        fapiaoModel = new FapiaoModel();
    }

    public void saveFapiaoData(Map<String, Object> map) {
        if (fapiaoView != null) {
            fapiaoModel.saveFapiaoData(map, new Subscriber<FapiaoBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    fapiaoView.showError((Exception) e);
                }

                @Override
                public void onNext(FapiaoBean fapiaoBean) {
                    fapiaoView.saveFapiaoData(fapiaoBean);
                }
            });
        }
    }
}
